<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    ul{
      list-style-type: none;
      display: flex;
      flex-wrap: wrap;
    }
    li{
      width:25%;
      background-color: pink;
    }
  </style>
</head>

<body>
  <div id="app">
    <ul>
      <li v-for="film in films" :key="film.filmId">
        <img :src="film.poster" alt="">
        <h2>{{film.name}}</h2>
      </li>
    </ul>
  </div>

  <script src="./vue.js"></script>
  <script src="./axios.js"></script>
  <script>
    const vm = new Vue({
      el: "#app",
      data: {
        films:[]
      },
      created(){
        this.fetchFilmData()
      },
      methods:{
        fetchFilmData(){
          // 封装了 请求 数据函数
          axios.get('https://m.maizuo.com/gateway',{
            params:{
              cityId:'110100',
              pageNum:'1',
              pageSize:'10',
              type:'1',
              k:'2183988'
            },
            headers:{ // 设置请求头
              "X-Client-Info":'{"a":"3000","ch":"1002","v":"5.0.4","e":"1597720815568988677439489","bc":"110100"}',
              "X-Host":"mall.film-ticket.film.list"
            }
          }).then(res=>{
            console.log(res)
            if(res.data.status=== 0 ){
              this.films = res.data.data.films
            }
          })
        }
      }
    })
    // cors 跨站资源共享 后端 设置 接口访问 白名单
  </script>
</body>

</html>
